/*
 * @Author: WangZhiJie
 * @Date: 2024-03-28 16:53:18
 * @LastEditTime: 2024-04-03 09:22:49
 * @Description: 
 * @FilePath: \ga-smart-city-app-front\src\pages\publicService\serviceScore.tsx
 */
// @ts-nocheck
/*
 * @Author: WangZhiJie
 * @Date: 2024-03-26 14:54:33
 * @LastEditTime: 2024-04-03 09:21:41
 * @Description: 
 * @FilePath: \ga-smart-city-app-front\src\pages\publicService\serviceScore.tsx
 */
import React, { useState, useEffect } from "react";
import { useLocation,useNavigate } from "react-router-dom";
import { Rate, Button, TextArea, NavBar } from 'antd-mobile';
import {useSelector,useDispatch} from 'react-redux';
import { PageHeader } from '@/components'
import "./index.less";
const ServiceScore: React.FC = () => {
    const dispatch = useDispatch();
    const navigate = useNavigate();
    const serviceEnterParams = useSelector((state: any) => state.serviceEnterParams.serviceParams)
    const location = useLocation().state;
    const [evaluateDesc, setEvaluateDesc] = useState<string>('');
    const [score, setScore] = useState<number>(null);
    useEffect(()=>{
        setEvaluateDesc(serviceEnterParams.evaluateDesc)
        setScore(serviceEnterParams.score)
    },[serviceEnterParams])
    const onConfig = () => {
        dispatch({
            type:'serviceEnterParams/onServiceEnterParams',
            payload: {
                evaluateDesc,
                score
            }
        })
        window.history.back()
    }
    return <div className="serviceCentent serviceScore">
        <div className="header">
			<div>
				<NavBar onBack={() => navigate(-1)}>
					<div className="commontitle">服务录入</div>
				</NavBar>
			</div>
		</div>
        <div className="centent_box">
            <div className="list_box" style={{minHeight:'auto'}}>
                <div className="list" style={{ margin: 0, border: 0, padding: 0 }}>
                    <div className="text title"><span>{location?.serveName}</span></div>
                    <div className="text"><span>{[location?.serveOrganization, location?.serveType].join('-')}</span></div>
                    <div className="text">{[location?.startTime,location?.endTime].join('/')}</div>
                </div>
            </div>
            <div className="score_title">评分</div>
            <Rate
                allowHalf
                value={score}
                onChange={(v) => {
                    setScore(v)
                }}
            />
            <TextArea
                value={evaluateDesc}
                style={{ marginTop: '2rem' }}
                onChange={(v) => {
                    setEvaluateDesc(v)
                }}
                placeholder='请输入评价内容...'
                autoSize={{ minRows: 3, maxRows: 5 }}
            />
        </div>
        <div className="footer_btn">
            <Button color="primary" type="submit" onClick={onConfig}>确定</Button>
        </div>
    </div>
}
export default ServiceScore